public class quick_sort {
    private static void quick_sort(int[] array, int low, int high) {
        if(low < high){
            int left = low, right = high;
            int pivot = array[low];
            while(left < right){
                while(left < right && array[right] >= pivot)
                    right--;
                if(left < right)
                    array[left++] = array[right];
                while(left < right && array[left] < pivot)
                    left++;
                if(left < right)
                    array[right--] = array[left];
            }
            array[left] = pivot;
            quick_sort(array, low, left-1);
            quick_sort(array, right+1, high);
        }
    }

    public static void main(String[] args) {
        int[] my_array = {1, 9, 45, 7, 15, -5, 2, 74, -27, 10};
        quick_sort(my_array, 0, my_array.length-1);
        for (int i = 0; i < my_array.length; i++)
            System.out.printf("%d ", my_array[i]);
        System.out.println();
    }
}
